package com.dgty.dg_common.base

import android.annotation.SuppressLint
import android.os.Bundle
import android.view.View
import androidx.databinding.ViewDataBinding
import com.dgty.dg_common.R
import com.gyf.immersionbar.BarHide
import com.gyf.immersionbar.ImmersionBar

/**
 * Title: BaseVMFragment.kt
 * Description:
 * Created DateTime: 2023-02-08
 * Created by xxl.
 */
abstract class BaseVMFragment<T : ViewDataBinding> : BaseFragment<T>() {
    protected var currentPage = 0
    protected var currentPageSize = 10
    private var isFirstLoad: Boolean = true

    abstract fun observe()
    abstract fun init()

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        observe()
        init()
    }

    override fun onResume() {
        super.onResume()
        if (isFirstLoad) {
            isFirstLoad = false
            lazyLoad()
        }
    }

    open fun lazyLoad() {}

    open fun resetState() {}

    //状态栏颜色
    private val barColor: Int = R.color.white
    private val statusBarColor: Int = R.color.color_33000000
    var showBarAndPadding = 0
    var hideBarAndPadding = 1
    private val darkText = true

    @SuppressLint("ResourceType")
    protected open fun immersionBarShow(type:Int) {
     /*   var  immersionBar = ImmersionBar.with(this).statusBarDarkFont(true)
        if (type == showBarAndPadding) {
            immersionBar.reset()
            immersionBar.hideBar(BarHide.FLAG_SHOW_BAR)
            immersionBar.statusBarColor(barColor) //状态栏颜色
                .navigationBarColor(statusBarColor) //导航栏颜色
                .statusBarDarkFont(darkText) //状态栏深色字体
                .statusBarAlpha(0.0f) //状态栏透明度
                .navigationBarAlpha(0.4f) //导航栏透明度
                .fullScreen(true) //全屏
            immersionBar.init()

        } else if (type == hideBarAndPadding) {
            immersionBar.reset()
            immersionBar.hideBar(BarHide.FLAG_HIDE_BAR)
            immersionBar.init()

            mBind.root.setPadding(0, 0, 0, 0)
        }*/
    }
}